﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace AconITF.Utils
{
	public sealed class CPUTimer
	{
		[DllImport("kernel32.dll")]
		public static extern bool QueryPerformanceCounter(out long lpPerCount);


		[DllImport("kernel32.dll")]
		public static extern bool QueryPerformanceFrequency(out long lpPerCount);

		/// <summary>
		/// 获取CPU时间 单位：毫秒
		/// </summary>
		public static uint GetCpuTick()
		{
			QueryPerformanceFrequency(out var frequency);
			QueryPerformanceCounter(out var nowTime);
			return (uint)(nowTime * 1000 / (double)frequency);
		}
	}
}
